package wevil.spring.daooracle.impl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import wevil.spring.conf.CustomerContextHolder;
import wevil.spring.daooracle.ScRoleDao;
import wevil.spring.domainoracle.ScRole;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/11/2.
 */
@Repository("ScRoleDaoImpl")
@Transactional
public class ScRoleDaoImpl implements ScRoleDao{
    @Resource
    private SessionFactory sessionFactory;


    public Session getSession() {
        CustomerContextHolder.setCustomerType(CustomerContextHolder.SESSION_FACTORY_ORACLE);
        return sessionFactory.openSession();
    }


    public List<ScRole> queryAll() {
        return getSession().createQuery("FROM " + ScRole.class.getSimpleName()).list();

    }
}
